package io;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;

public class Demo2 {
    public static void main(String[] args) throws IOException {
        /*
        Reader reader = new FileReader("d:/test.txt");
        try {
            while (true) {
                char[] cbuf = new char[3];
                int n = reader.read(cbuf);
                if (n == -1) {
                    break;
                }
                for (int i = 0; i < n; i++) {
                    System.out.println(cbuf[i]);
                }
            }
        } finally {
            reader.close();
        }*/

        try (Reader reader = new FileReader("d:/test.txt")) {
            while (true) {
                char[] cbuf = new char[3];
                int n = reader.read(cbuf);
                if (n == -1) {
                    break;
                }
                for (int i = 0; i < n; i++) {
                    System.out.println(cbuf[i]);
                }

            }
        }
    }
}